      <template>
  <div>
    <template v-for="(item, index) in options" :key="item.value">
      <template v-if="values.includes(item.value)">
        <span
          v-if="
            (item.elTagType == 'default' || item.elTagType == '') &&
            (item.elTagClass == '' || item.elTagClass == null)
          "
          :key="item.value"
          :index="index"
          :class="item.elTagClass"
          >{{ item.label + " " }}</span
        >
        <el-tag
          v-else
          :disable-transitions="true"
          :key="item.value + ''"
          :index="index"
          :type="item.elTagType === 'primary' ? '' : item.elTagType"
          :class="item.elTagClass"
          >{{ item.label + " " }}</el-tag
        >
      </template>
    </template>
    <template v-if="unmatch && showValue">
      {{ formattedUnmatchArray }}
    </template>
  </div>
</template>
      
      <script setup>
import { ref, computed } from "vue";

// 记录未匹配的项
const unmatchArray = ref([]);

const props = defineProps({
  // 数据
  options: {
    type: Array,
    default: () => [],
  },
  // 当前的值
  value: [Number, String, Array],
  // 当未找到匹配的数据时，显示value
  showValue: {
    type: Boolean,
    default: true,
  },
  separator: {
    type: String,
    default: ",",
  },
});

const values = computed(() => {
  if (
    props.value === null ||
    typeof props.value === "undefined" ||
    props.value === ""
  )
    return [];
  return Array.isArray(props.value)
    ? props.value.map((item) => "" + item)
    : String(props.value).split(props.separator);
});

const unmatch = computed(() => {
  unmatchArray.value = [];
  // 没有value不显示
  if (
    props.value === null ||
    typeof props.value === "undefined" ||
    props.value === "" ||
    props.options.length === 0
  )
    return false;
  // 传入值为数组
  let hasUnmatch = false; // 添加一个标志来判断是否有未匹配项
  values.value.forEach((item) => {
    if (!props.options.some((v) => v.value === item)) {
      unmatchArray.value.push(item);
      hasUnmatch = true; // 如果有未匹配项，将标志设置为true
    }
  });
  return hasUnmatch; // 返回标志的值
});

// 替代过滤器的逻辑
const formattedUnmatchArray = computed(() => {
  if (unmatchArray.value.length === 0) return "";
  return unmatchArray.value.join(" ");
});
</script>
      
      <style scoped>
.el-tag + .el-tag {
  margin-left: 10px;
}
</style>